package com.song.tools.songtest.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.song.tools.core.util.ObjectUtils;
import com.song.tools.mvc.manager.BaseManager;
import com.song.tools.songtest.beans.bo.DictionaryBo;
import com.song.tools.songtest.beans.query.DictionaryQuery;
import com.song.tools.songtest.convertor.DictionaryConvertor;
import com.song.tools.songtest.dao.entity.Dictionary;
import com.song.tools.songtest.dao.mapper.DictionaryMapper;
import org.springframework.stereotype.Component;

/**
 * 字典manager
 *
 * @author song tools
 */
@Component
public class DictionaryManager extends BaseManager<Dictionary, DictionaryBo, DictionaryMapper, DictionaryQuery, Long, DictionaryConvertor> {

    @Override
    public LambdaQueryWrapper<Dictionary> encapsulateQueryWrapper(DictionaryQuery request) {
        LambdaQueryWrapper<Dictionary> queryWrapper = super.encapsulateQueryWrapper(request);
        if (request == null) {
            return queryWrapper;
        }

        queryWrapper.eq(ObjectUtils.isNotEmpty(request.getId()), Dictionary::getId, request.getId());
        queryWrapper.eq(ObjectUtils.isNotEmpty(request.getDictionaryId()), Dictionary::getDictionaryId, request.getDictionaryId());
        queryWrapper.eq(ObjectUtils.isNotEmpty(request.getCode()), Dictionary::getCode, request.getCode());
        return queryWrapper;
    }
}
